{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "# Polygons\n",
    "\n",
    "Concentric polygons with increasing number of sides."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       "  \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<!-- Created with matplotlib (https://matplotlib.org/) -->\n",
       "<svg height=\"231.84pt\" version=\"1.1\" viewBox=\"0 0 349.2 231.84\" width=\"349.2pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
       " <metadata>\n",
       "  <rdf:RDF xmlns:cc=\"http://creativecommons.org/ns#\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n",
       "   <cc:Work>\n",
       "    <dc:type rdf:resource=\"http://purl.org/dc/dcmitype/StillImage\"/>\n",
       "    <dc:date>2020-08-12T16:01:13.928970</dc:date>\n",
       "    <dc:format>image/svg+xml</dc:format>\n",
       "    <dc:creator>\n",
       "     <cc:Agent>\n",
       "      <dc:title>Matplotlib v3.3.0, https://matplotlib.org/</dc:title>\n",
       "     </cc:Agent>\n",
       "    </dc:creator>\n",
       "   </cc:Work>\n",
       "  </rdf:RDF>\n",
       " </metadata>\n",
       " <defs>\n",
       "  <style type=\"text/css\">*{stroke-linecap:butt;stroke-linejoin:round;}</style>\n",
       " </defs>\n",
       " <g id=\"figure_1\">\n",
       "  <g id=\"patch_1\">\n",
       "   <path d=\"M 0 231.84 \n",
       "L 349.2 231.84 \n",
       "L 349.2 0 \n",
       "L 0 0 \n",
       "z\n",
       "\" style=\"fill:none;\"/>\n",
       "  </g>\n",
       "  <g id=\"axes_1\">\n",
       "   <g id=\"patch_2\">\n",
       "    <path clip-path=\"url(#p6442ff6114)\" d=\"M 325.095237 9.905484 \n",
       "L 327.800721 9.905484 \n",
       "L 327.800721 224.64 \n",
       "L 24.104763 224.64 \n",
       "L 24.104763 221.934516 \n",
       "L 325.095237 221.934516 \n",
       "z\n",
       "\" style=\"opacity:0.3;\"/>\n",
       "   </g>\n",
       "   <g id=\"LineCollection_1\">\n",
       "    <path clip-path=\"url(#p6442ff6114)\" d=\"M 173.247258 110.477077 \n",
       "L 176.789459 116.612348 \n",
       "L 169.705057 116.612348 \n",
       "L 173.247258 110.477077 \n",
       "\" style=\"fill:none;stroke:#0000ff;stroke-opacity:0.5;\"/>\n",
       "    <path clip-path=\"url(#p6442ff6114)\" d=\"M 173.247258 106.386895 \n",
       "L 181.42762 114.567258 \n",
       "L 173.247258 122.74762 \n",
       "L 165.066895 114.567258 \n",
       "L 173.247258 106.386895 \n",
       "\" style=\"fill:none;stroke:#0000ff;stroke-opacity:0.5;\"/>\n",
       "    <path clip-path=\"url(#p6442ff6114)\" d=\"M 173.247258 102.296714 \n",
       "L 184.917238 110.775451 \n",
       "L 180.459702 124.494336 \n",
       "L 166.034813 124.494336 \n",
       "L 161.577277 110.775451 \n",
       "L 173.247258 102.296714 \n",
       "\" style=\"fill:none;stroke:#0000ff;stroke-opacity:0.5;\"/>\n",
       "    <path clip-path=\"url(#p6442ff6114)\" d=\"M 173.247258 98.206533 \n",
       "L 187.416061 106.386895 \n",
       "L 187.416061 122.74762 \n",
       "L 173.247258 130.927983 \n",
       "L 159.078454 122.74762 \n",
       "L 159.078454 106.386895 \n",
       "L 173.247258 98.206533 \n",
       "\" style=\"fill:none;stroke:#0000ff;stroke-opacity:0.5;\"/>\n",
       "    <path clip-path=\"url(#p6442ff6114)\" d=\"M 173.247258 94.116352 \n",
       "L 189.23642 101.816326 \n",
       "L 193.185417 119.118013 \n",
       "L 182.120573 132.992888 \n",
       "L 164.373942 132.992888 \n",
       "L 153.309098 119.118013 \n",
       "L 157.258095 101.816326 \n",
       "L 173.247258 94.116352 \n",
       "\" style=\"fill:none;stroke:#0000ff;stroke-opacity:0.5;\"/>\n",
       "    <path clip-path=\"url(#p6442ff6114)\" d=\"M 173.247258 90.02617 \n",
       "L 190.600427 97.214088 \n",
       "L 197.788345 114.567258 \n",
       "L 190.600427 131.920427 \n",
       "L 173.247258 139.108345 \n",
       "L 155.894088 131.920427 \n",
       "L 148.70617 114.567258 \n",
       "L 155.894088 97.214088 \n",
       "L 173.247258 90.02617 \n",
       "\" style=\"fill:none;stroke:#0000ff;stroke-opacity:0.5;\"/>\n",
       "    <path clip-path=\"url(#p6442ff6114)\" d=\"M 173.247258 85.935989 \n",
       "L 191.651083 92.634433 \n",
       "L 201.443553 109.59549 \n",
       "L 198.042664 128.882892 \n",
       "L 183.039728 141.47185 \n",
       "L 163.454787 141.47185 \n",
       "L 148.451852 128.882892 \n",
       "L 145.050962 109.59549 \n",
       "L 154.843433 92.634433 \n",
       "L 173.247258 85.935989 \n",
       "\" style=\"fill:none;stroke:#0000ff;stroke-opacity:0.5;\"/>\n",
       "    <path clip-path=\"url(#p6442ff6114)\" d=\"M 173.247258 81.845808 \n",
       "L 192.480443 88.095049 \n",
       "L 204.367206 104.455774 \n",
       "L 204.367206 124.678742 \n",
       "L 192.480443 141.039467 \n",
       "L 173.247258 147.288708 \n",
       "L 154.014072 141.039467 \n",
       "L 142.12731 124.678742 \n",
       "L 142.12731 104.455774 \n",
       "L 154.014072 88.095049 \n",
       "L 173.247258 81.845808 \n",
       "\" style=\"fill:none;stroke:#0000ff;stroke-opacity:0.5;\"/>\n",
       "    <path clip-path=\"url(#p6442ff6114)\" d=\"M 173.247258 77.755627 \n",
       "L 193.149128 83.599343 \n",
       "L 206.732295 99.275153 \n",
       "L 209.6842 119.806099 \n",
       "L 201.067632 138.67375 \n",
       "L 183.618293 149.887759 \n",
       "L 162.876223 149.887759 \n",
       "L 145.426883 138.67375 \n",
       "L 136.810316 119.806099 \n",
       "L 139.76222 99.275153 \n",
       "L 153.345387 83.599343 \n",
       "L 173.247258 77.755627 \n",
       "\" style=\"fill:none;stroke:#0000ff;stroke-opacity:0.5;\"/>\n",
       "    <path clip-path=\"url(#p6442ff6114)\" d=\"M 173.247258 73.665445 \n",
       "L 193.698164 79.145249 \n",
       "L 208.669266 94.116352 \n",
       "L 214.14907 114.567258 \n",
       "L 208.669266 135.018164 \n",
       "L 193.698164 149.989266 \n",
       "L 173.247258 155.46907 \n",
       "L 152.796352 149.989266 \n",
       "L 137.825249 135.018164 \n",
       "L 132.345445 114.567258 \n",
       "L 137.825249 94.116352 \n",
       "L 152.796352 79.145249 \n",
       "L 173.247258 73.665445 \n",
       "\" style=\"fill:none;stroke:#0000ff;stroke-opacity:0.5;\"/>\n",
       "    <path clip-path=\"url(#p6442ff6114)\" d=\"M 173.247258 69.575264 \n",
       "L 194.15608 74.728826 \n",
       "L 210.274943 89.008892 \n",
       "L 217.911209 109.144072 \n",
       "L 215.315503 130.521639 \n",
       "L 203.082468 148.244249 \n",
       "L 184.014547 158.251866 \n",
       "L 162.479969 158.251866 \n",
       "L 143.412047 148.244249 \n",
       "L 131.179013 130.521639 \n",
       "L 128.583306 109.144072 \n",
       "L 136.219573 89.008892 \n",
       "L 152.338436 74.728826 \n",
       "L 173.247258 69.575264 \n",
       "\" style=\"fill:none;stroke:#0000ff;stroke-opacity:0.5;\"/>\n",
       "    <path clip-path=\"url(#p6442ff6114)\" d=\"M 173.247258 65.485083 \n",
       "L 194.543215 70.345746 \n",
       "L 211.621247 83.965022 \n",
       "L 221.09884 103.645446 \n",
       "L 221.09884 125.489069 \n",
       "L 211.621247 145.169493 \n",
       "L 194.543215 158.788769 \n",
       "L 173.247258 163.649433 \n",
       "L 151.9513 158.788769 \n",
       "L 134.873268 145.169493 \n",
       "L 125.395675 125.489069 \n",
       "L 125.395675 103.645446 \n",
       "L 134.873268 83.965022 \n",
       "L 151.9513 70.345746 \n",
       "L 173.247258 65.485083 \n",
       "\" style=\"fill:none;stroke:#0000ff;stroke-opacity:0.5;\"/>\n",
       "    <path clip-path=\"url(#p6442ff6114)\" d=\"M 173.247258 61.394902 \n",
       "L 194.874403 65.991893 \n",
       "L 212.762019 78.988007 \n",
       "L 223.817174 98.136096 \n",
       "L 226.12833 120.125282 \n",
       "L 219.295869 141.153436 \n",
       "L 204.501185 157.584598 \n",
       "L 184.302412 166.57767 \n",
       "L 162.192103 166.57767 \n",
       "L 141.993331 157.584598 \n",
       "L 127.198646 141.153436 \n",
       "L 120.366185 120.125282 \n",
       "L 122.677342 98.136096 \n",
       "L 133.732496 78.988007 \n",
       "L 151.620112 65.991893 \n",
       "L 173.247258 61.394902 \n",
       "\" style=\"fill:none;stroke:#0000ff;stroke-opacity:0.5;\"/>\n",
       "    <path clip-path=\"url(#p6442ff6114)\" d=\"M 173.247258 57.30472 \n",
       "L 195.160682 61.663571 \n",
       "L 213.737986 74.076529 \n",
       "L 226.150944 92.653833 \n",
       "L 230.509795 114.567258 \n",
       "L 226.150944 136.480682 \n",
       "L 213.737986 155.057986 \n",
       "L 195.160682 167.470944 \n",
       "L 173.247258 171.829795 \n",
       "L 151.333833 167.470944 \n",
       "L 132.756529 155.057986 \n",
       "L 120.343571 136.480682 \n",
       "L 115.98472 114.567258 \n",
       "L 120.343571 92.653833 \n",
       "L 132.756529 74.076529 \n",
       "L 151.333833 61.663571 \n",
       "L 173.247258 57.30472 \n",
       "\" style=\"fill:none;stroke:#0000ff;stroke-opacity:0.5;\"/>\n",
       "    <path clip-path=\"url(#p6442ff6114)\" d=\"M 173.247258 53.214539 \n",
       "L 195.410416 57.357551 \n",
       "L 214.580317 69.227052 \n",
       "L 228.167959 87.219998 \n",
       "L 234.338257 108.906343 \n",
       "L 232.257876 131.357226 \n",
       "L 222.207784 151.540531 \n",
       "L 205.545302 166.730391 \n",
       "L 184.52079 174.87533 \n",
       "L 161.973725 174.87533 \n",
       "L 140.949213 166.730391 \n",
       "L 124.286731 151.540531 \n",
       "L 114.23664 131.357226 \n",
       "L 112.156259 108.906343 \n",
       "L 118.326556 87.219998 \n",
       "L 131.914198 69.227052 \n",
       "L 151.084099 57.357551 \n",
       "L 173.247258 53.214539 \n",
       "\" style=\"fill:none;stroke:#0000ff;stroke-opacity:0.5;\"/>\n",
       "    <path clip-path=\"url(#p6442ff6114)\" d=\"M 173.247258 49.124358 \n",
       "L 195.630048 53.071048 \n",
       "L 215.313143 64.435088 \n",
       "L 229.922472 81.845808 \n",
       "L 237.695933 103.203217 \n",
       "L 237.695933 125.931298 \n",
       "L 229.922472 147.288708 \n",
       "L 215.313143 164.699428 \n",
       "L 195.630048 176.063468 \n",
       "L 173.247258 180.010158 \n",
       "L 150.864468 176.063468 \n",
       "L 131.181373 164.699428 \n",
       "L 116.572044 147.288708 \n",
       "L 108.798582 125.931298 \n",
       "L 108.798582 103.203217 \n",
       "L 116.572044 81.845808 \n",
       "L 131.181373 64.435088 \n",
       "L 150.864468 53.071048 \n",
       "L 173.247258 49.124358 \n",
       "\" style=\"fill:none;stroke:#0000ff;stroke-opacity:0.5;\"/>\n",
       "    <path clip-path=\"url(#p6442ff6114)\" d=\"M 173.247258 45.034177 \n",
       "L 195.824612 48.801671 \n",
       "L 215.95536 59.695887 \n",
       "L 231.458022 76.536267 \n",
       "L 240.652645 97.497895 \n",
       "L 242.542848 120.309254 \n",
       "L 236.923799 142.498378 \n",
       "L 224.404408 161.660732 \n",
       "L 206.341347 175.719778 \n",
       "L 184.692027 183.151998 \n",
       "L 161.802489 183.151998 \n",
       "L 140.153169 175.719778 \n",
       "L 122.090107 161.660732 \n",
       "L 109.570717 142.498378 \n",
       "L 103.951667 120.309254 \n",
       "L 105.84187 97.497895 \n",
       "L 115.036493 76.536267 \n",
       "L 130.539155 59.695887 \n",
       "L 150.669903 48.801671 \n",
       "L 173.247258 45.034177 \n",
       "\" style=\"fill:none;stroke:#0000ff;stroke-opacity:0.5;\"/>\n",
       "    <path clip-path=\"url(#p6442ff6114)\" d=\"M 173.247258 40.943995 \n",
       "L 195.998097 44.547374 \n",
       "L 216.521926 55.004787 \n",
       "L 232.809728 71.29259 \n",
       "L 243.267141 91.816418 \n",
       "L 246.87052 114.567258 \n",
       "L 243.267141 137.318097 \n",
       "L 232.809728 157.841926 \n",
       "L 216.521926 174.129728 \n",
       "L 195.998097 184.587141 \n",
       "L 173.247258 188.19052 \n",
       "L 150.496418 184.587141 \n",
       "L 129.97259 174.129728 \n",
       "L 113.684787 157.841926 \n",
       "L 103.227374 137.318097 \n",
       "L 99.623995 114.567258 \n",
       "L 103.227374 91.816418 \n",
       "L 113.684787 71.29259 \n",
       "L 129.97259 55.004787 \n",
       "L 150.496418 44.547374 \n",
       "L 173.247258 40.943995 \n",
       "\" style=\"fill:none;stroke:#0000ff;stroke-opacity:0.5;\"/>\n",
       "    <path clip-path=\"url(#p6442ff6114)\" d=\"M 173.247258 36.853814 \n",
       "L 196.153697 40.306404 \n",
       "L 217.024799 50.357397 \n",
       "L 234.006075 66.113718 \n",
       "L 245.588662 86.175349 \n",
       "L 250.743399 108.759725 \n",
       "L 249.012263 131.860126 \n",
       "L 240.549074 153.42398 \n",
       "L 226.105824 171.535243 \n",
       "L 206.965857 184.584651 \n",
       "L 184.829846 191.412707 \n",
       "L 161.66467 191.412707 \n",
       "L 139.528658 184.584651 \n",
       "L 120.388692 171.535243 \n",
       "L 105.945441 153.42398 \n",
       "L 97.482252 131.860126 \n",
       "L 95.751117 108.759725 \n",
       "L 100.905853 86.175349 \n",
       "L 112.488441 66.113718 \n",
       "L 129.469716 50.357397 \n",
       "L 150.340818 40.306404 \n",
       "L 173.247258 36.853814 \n",
       "\" style=\"fill:none;stroke:#0000ff;stroke-opacity:0.5;\"/>\n",
       "    <path clip-path=\"url(#p6442ff6114)\" d=\"M 173.247258 32.763633 \n",
       "L 196.294002 36.077254 \n",
       "L 217.473636 45.749669 \n",
       "L 235.070313 60.997276 \n",
       "L 247.658452 80.584804 \n",
       "L 254.21824 102.925388 \n",
       "L 254.21824 126.209127 \n",
       "L 247.658452 148.549712 \n",
       "L 235.070313 168.13724 \n",
       "L 217.473636 183.384846 \n",
       "L 196.294002 193.057261 \n",
       "L 173.247258 196.370883 \n",
       "L 150.200513 193.057261 \n",
       "L 129.020879 183.384846 \n",
       "L 111.424203 168.13724 \n",
       "L 98.836063 148.549712 \n",
       "L 92.276276 126.209127 \n",
       "L 92.276276 102.925388 \n",
       "L 98.836063 80.584804 \n",
       "L 111.424203 60.997276 \n",
       "L 129.020879 45.749669 \n",
       "L 150.200513 36.077254 \n",
       "L 173.247258 32.763633 \n",
       "\" style=\"fill:none;stroke:#0000ff;stroke-opacity:0.5;\"/>\n",
       "   </g>\n",
       "   <g id=\"line2d_1\">\n",
       "    <path clip-path=\"url(#p6442ff6114)\" d=\"M 21.399279 7.2 \n",
       "L 325.095237 7.2 \n",
       "L 325.095237 221.934516 \n",
       "L 21.399279 221.934516 \n",
       "L 21.399279 7.2 \n",
       "\" style=\"fill:none;stroke:#000000;stroke-linecap:square;stroke-width:0.25;\"/>\n",
       "   </g>\n",
       "  </g>\n",
       " </g>\n",
       " <defs>\n",
       "  <clipPath id=\"p6442ff6114\">\n",
       "   <rect height=\"217.44\" width=\"334.8\" x=\"7.2\" y=\"7.2\"/>\n",
       "  </clipPath>\n",
       " </defs>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "import numpy as np\n",
    "\n",
    "import vsketch\n",
    "\n",
    "vsk = vsketch.Vsketch()\n",
    "vsk.size(\"a4\", landscape=True)\n",
    "vsk.scale(\"4mm\")\n",
    "\n",
    "phase = -np.pi / 2\n",
    "for i in range(20):\n",
    "    angles = np.linspace(0, 2 * np.pi, i + 4)\n",
    "    vsk.polygon((i + 1) * np.cos(angles + phase), (i + 1) * np.sin(angles + phase))\n",
    "\n",
    "vsk.display()\n",
    "vsk.save(\"polygons.svg\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
